/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package retemia;

import com.sun.jmx.remote.internal.ClientCommunicatorAdmin;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author paolo
 */
public class Server{
    public static void main(String[] args) throws IOException{
    Socket client=null;
    PrintWriter print= null;
    ServerSocket server= null;
    InputStream in;
    BufferedReader bin=null;
    try{
        server= new ServerSocket(5155);
        while(true){
            client=server.accept();
            print= new PrintWriter(client.getOutputStream());
            in= client.getInputStream();
            bin= new BufferedReader(new InputStreamReader(in));
            String[] line=new String[10];
            int i=0;
            while((line[i]=bin.readLine())!=null && i<11){
                i++;
            }
            for(i=0; i<line.length; i++){
                print.println(line[i]);
            }
            print.close();
            client.close();
        }
    }catch(IOException e){
        System.err.print(e);
    }finally{
        if(client!=null){
            client.close();
        }
        if(server!=null){
            server.close();
        }
    }

    }

}
